/*
 * Class Button
 */
Button.prototype = new Element();
Button.prototype.constructor = Element;
Button.prototype.text = '';
//determina cuando un button esta dentro de otro elemento o depende de un tag html existente
Button.prototype._isInner = false;
//puntero al objeto que lo contiene en el caso de ser inner
Button.prototype._parent = {};
Button.prototype.btButtonClass = 'btn';//btn-info, btn-success, btn-link, .., btn-block
Button.prototype.btButtonSize = '';//btn-large, btn-small, btn-mini

Button.prototype.makeHtml = function(){
    var cssWidth = "";
    
    
    this.Classes.push(this.CLASSNAMES.BUTTON);
    this.Classes.push(this.btButtonClass);
    this.Classes.push(this.btButtonSize);
    
    if(this.width == '100%')    this.Classes.push('btn-block');
    else{
        if(this.width){
            cssWidth = ' width:'+this.width;
        }
    }
    
    var classes = this._getClassesString();
    return '<button style="'+cssWidth+'" rck-id="'+this._id+'" id="'+this.id+'" class="'+classes+'" type="button">'+this.text+'</button>';
};
//
Button.prototype.create = function(options){
//    this._id = this.makeUId();
    var _this = this;
    
    this.setOptions(options);
    
    var jId = "#"+this.id;
    var jRenderTo = "#"+this.renderTo;
    
    //si posee tag donde insertar html
    if(this.renderTo){
        //create DOM element
        jQuery(jRenderTo).html(this.makeHtml());
        
        //setting widths
        if(this.width)
            this.setWidth(this.width);
        if(this.height)
            this.setHeight(this.height);
        
        //the object exist in DOM, we create the handler event
        if(this.handler){//clic the button
            jQuery(jRenderTo).click(function(){
                _this.handler(_this);
            });
        }
    }
    else{
        if(this.handler){
            jQuery(jId).live('click',function(){
                _this.handler(_this);
            });
        }
    }
    
    return this;
}

function Button(options){
    this.create(options);
}